
<template>
  <div id="changePassword">
    <div class="top">
      <input v-model="op" type="password" placeholder="请输入原密码">
      <input v-model="np" type="password" placeholder="请输入新密码">
      <input v-model="rp" type="password" placeholder="请重复输入新密码">
    </div>
    <a href="javascript:;" @click="changeP">保存</a>
    <tabbar>
      <tabbar-item link="/code">
        <img slot="icon" src="../../../wechat/static/images/tab_hx_n.png">
        <span slot="label" style="font-family: PingFang-SC-Medium;
    font-size: 0.24rem;
    color: #999999;">核销</span>
      </tabbar-item>
      <tabbar-item link="/orderData">
        <img slot="icon" src="../../../wechat/static/images/tab_ddsj_n.png">
        <span slot="label" style="font-family: PingFang-SC-Medium;
    font-size: 0.24rem;
    color: #999999;">订单数据</span>
      </tabbar-item>
      <tabbar-item selected>
        <img slot="icon" src="../../../wechat/static/images/tab_grzx_s.png">
        <span slot="label" style="font-family: PingFang-SC-Medium;
    font-size: 0.24rem;
    color: #ec1b24;">个人中心</span>
      </tabbar-item>
    </tabbar>
  </div>
</template>

<script>
import { Tabbar, TabbarItem } from "vux";
export default {
  name: "changePassword",
  data() {
    return {
      op:'',
      np:'',
      rp:''
    };
  },
  mounted() {
  },
  created() {
    
  },
  methods: {
    changeP() {
      if(!this.op||!this.np||!this.rp){
        this.$vux.toast.show({
          text: "密码不能为空",
          type: "warn",
              width: 'auto'
        });
        return
      }
      if(this.np!==this.rp){
        this.$vux.toast.show({
          text: "两次输入的密码不同，请重新输入",
          type: "warn",
              width: 'auto'
        });
        return
      }
      if(this.op!==localStorage.getItem('storeP')){
        this.$vux.toast.show({
          text: "旧密码错误，请重新输入",
          type: "warn",
              width: 'auto'
        });
        return
      }
      var param = {
        id: localStorage.getItem('storeId')||'',
        pwd: this.np,
        pwd2: this.rp,
        storeName: localStorage.getItem('storeName')||'',
        brandId: localStorage.getItem('storeBrandId')||'',
        userName: localStorage.getItem('storeUserName')||'',
        brandName: localStorage.getItem('storeBrandName')||'',
      };
      var url = this.$CONSTANT.STORE.saveEsStore+'?sessionId='+this.$common.getCookie("sessionId");
      
      this.$vux.loading.show({
        text: '正在提交数据'
      })
      setTimeout(() => {
        this.$common.post(url, param, res => {
          this.$vux.loading.hide()
          if (res.status == 200) {
            var bussData = res.data.bussData
            this.$vux.toast.show({
              text: res.msg,
              type: "",
              width: 'auto'
            });
            setTimeout(() => {
              this.$common.setCookie('storeId',this.np)
              this.$router.back()
            }, 1000);
          } else {
            this.$vux.toast.show({
              text: res.msg,
              type: "warn",
              width: 'auto'
            });
          }
        });
      }, 1000);
    }
  },
  components: {
    Tabbar,
    TabbarItem,
  }
};
</script>

<style lang="less">
#changePassword{
  background: #fff;
  .top{
    margin: 0 10px;
    input{
      width: 100%;
      padding: 0;
      height: 54px;
      line-height: 54px;
      border-bottom: 1px solid #efefef;
      font-family: PingFang-SC-Medium;
      font-size: 15px;
      color: #333;
    }
  }
  >a {
    position: fixed;
    bottom: 150px;
    left: 50%;
    margin-left: -30.5%;
    text-align: center;
    display: inline-block;
    width: 61%;
    height: 45px;
    line-height: 45px;
    border: 1px solid transparent;
    border-radius: 23px;
    background-color: #f02931;
    font-family: PingFang-SC-Bold;font-weight: 600;
    font-size: 15px;
    color: #fff;
    text-align: center;
    &:hover {
      background-color: #e1252c;
    }
  }
  .weui-tabbar {
    position: fixed;
    .weui-tabbar__item {
      img {
        width: 21px;
        height: 21px;
        margin-top: 3px;
      }
    }
    .weui-bar__item_on {
      img {
        width: 23px;
        height: 21px;
      }
      .weui-tabbar__label {
        span {
          font-family: PingFang-SC-Medium;
          font-size: 12px;
          color: #ec1b24;
        }
      }
    }
    &:before {
      border: none;
    }
  }
}

</style>
